<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>资源统计管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="layui/css/layui.css" media="all">
		<link rel="stylesheet" href="layui/css/modules/laydate/default/laydate.css" media="all">
		<link rel="stylesheet" href="layui/css/modules/layer/default/layer.css" media="all">
		<script src="js/click.js"></script>
		<!--引入jquery的js  -->
		<script src="js/jquery.min.js" charset="utf-8"></script>
	</head>
	<body class="layui-layout-body">
		<div class="layui-layout layui-layout-admin">
			<div class="layui-header">
				<div class="layui-logo">资源统计管理</div>
				<ul class="layui-nav layui-layout-right">
					<li class="layui-nav-item">
						<button type="button" id="signIn" class="layui-btn layui-btn-xs layui-byn-normal"
							style="display: none;"><i class="layui-icon">&#xe67b;</i>签到</button>
						<button type="button" id="signOut" class="layui-btn layui-btn-xs layui-byn-normal"
							style="display: none;"><i class="layui-icon">&#xe67a;</i>签退</button>
					</li>
					<li class="layui-nav-item" lay-unselect>
						<a href="javascript:;">
							<span id="spName"></span>欢迎进入！！！！
						</a>
						<dl class="layui-nav-child layui-anim layui-anim-upbit">
							<dd style="text-align: center;">
								<!-- <a href="#">修改密码</a> -->
							</dd>
							<dd style="text-align: center;">
								<a href="#" id="logout">安全退出</a>
							</dd>
						</dl>
					</li>
				</ul>
			</div>
			<!-- 测试12 -->


			<div class="layui-side layui-bg-black">
				<div class="layui-side-scroll" style="width: 200px;">
					<!-- 左侧垂直导航区域-->
					<ul class="layui-nav layui-nav-tree" lay-filter="side" id="nav_ul">
						<li class="layui-nav-item" style="height: 30px; text-align: center"></li>
					</ul>
				</div>
			</div>
			<!--tab标签-->
			<div class="layui-tab layui-tab-card site-demo-title x-main" lay-filter="x-tab" lay-allowclose="true"
				style="left: 200px;border-left: solid 2px #2299ee;">
				<ul class="layui-tab-title">
					<li class="layui-this welcome">桌面<i class="layui-icon layui-unselect layui-tab-close">ဆ</i></li>
				</ul>
				<div class="layui-tab-content site-demo site-demo-body">
					<div class="layui-tab-item layui-show">
						<!-- <iframe frameborder="0" src="./welcome.html" class="x-iframe"></iframe> -->
						<iframe frameborder="0" src="./echart.html" class="x-iframe"></iframe>
					</div>
				</div>
			</div>
			<div class="layui-footer" style="text-align:center;">
				<!-- 底部固定区域 -->
				资源统计管理
			</div>
		</div>
		</div>
		<script src="lib/layui/layui.js" charset="utf-8"></script>
		<script src="js/global.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/x-admin.js"></script>
		<script type="application/javascript">
			layui.config({
				base: './dist/'
			}).extend({
				notice: 'notice'
			});

			layui.use(['layer', 'notice'], function() {
				$ = layui.$;
				var notice = layui.notice;
				var layer = layui.layer;

				notice.options = {
					closeButton: true, //显示关闭按钮
					debug: false, //启用debug
					positionClass: "toast-bottom-right", //弹出的位置,
					//showDuration:"300",//显示的时间
					// hideDuration:"1000",//消失的时间
					// timeOut:"2000",//停留的时间
					//extendedTimeOut:"1000",//控制时间
					showEasing: "swing", //显示时的动画缓冲方式
					hideEasing: "linear", //消失时的动画缓冲方式
					iconClass: 'toast-info', // 自定义图标，有内置，如不需要则传空 支持layui内置图标/自定义iconfont类名
					onclick: function() { // 点击关闭回调
						//window.location.href="zspt/ckrz.html";
						layer.open({
							type: 2,
							title: '消息列表',
							shadeClose: true,
							shade: 0.8,
							area: ['70%', '70%'],
							shadeClose: false,
							content: 'zspt/ckrz.html'
						})
					},
				};
				//ajax调用后台，查询当前登录的咨询师当天是否有未读的消息，如果有
				$.ajax({
					type: 'post', //提交方式 get或者post
					url: globalData.server + 'message/findMessageDanMu', //提交url
					data: {
						"receiverid": globalData.getCurUid(),
						"token": globalData.token
					}, //参数
					dataType: 'json', //返回数据的格式
					success: function(res) { //成功返回之后的调用
						if (res.message == "xiaoxi") {
							// notice.warning("成功");
							// notice.success("大佬，我咋知道怎么肥四！");
							notice.info("你有新的消息，请点击查阅！");
							// notice.error("大佬，我咋知道怎么肥四！");
						}
					},
					error: function() {

					}
				});


				$("#spName").html(globalData.getCurUName());
				//安全退出
				$("#logout").click(function() {
					layer.confirm('你确定要退出吗?', {
						icon: 3,
						title: '退出系统'
					}, function(index) {
						layer.close(index);
						//清空缓存数据并跳转到登录页
						globalData.setUserInfo(null, null, null);
						top.location.href = "login.html";
					}, function(index) {
						layer.close(index);
					});
				});
			});

			$(function() {
				$.ajax({
					type: 'get', //提交方式get或post
					url: "" + globalData.server + "userChecks/selectSignIn", //提交路径 globalData.server+'login'
					data: {
						"userid": globalData.getCurUid(),
						"token": globalData.token
					}, //参数
					dataType: 'json',
					success: function(res) {
						if (res.data == "" || res.data == null) {
							//当天考勤没数据，则显示签到按钮
							$('#signIn').show();
							$('#signOut').hide();
						} else if (res.data.checkstate == "1") {
							//已签到，则显示签退按钮
							$('#signIn').hide();
							$('#signOut').show();
						} else if (res.data.checkstate == "2") {
							//已签退，则两个按钮都不显示
							$('#signIn').hide();
							$('#signOut').hide();
						}
					},
					error: function() {
						alert("获取失败！！！");
					}
				})
			});

			$("#signIn").click(function() {
				$.ajax({
					type: 'post', //提交方式get或post
					url: "" + globalData.server + "userChecks/insertSignIn", //提交路径 globalData.server+'login'
					data: {
						"userid": globalData.getCurUid(),
						"username": globalData.getCurUName(),
						"token": globalData.token
					}, //参数
					dataType: 'json',
					success: function(res) {
						if (res == true) {
							layer.msg("签到成功！");
							//当天考勤没数据，则显示签到按钮
							$('#signIn').hide();
							$('#signOut').show();
						} else {
							layer.msg("签到失败！");
						}

					},
					error: function() {
						alert("获取失败！！！");
					}
				})
			})

			$("#signOut").click(function() {
				$.ajax({
					type: 'post', //提交方式get或post
					url: "" + globalData.server + "userChecks/updateSignIn", //提交路径 globalData.server+'login'
					data: {
						"userid": globalData.getCurUid(),
						"token": globalData.token
					}, //参数
					dataType: 'json',
					success: function(res) {
						//if(res.message == 'success'){
						if (res == true) {
							layer.msg("签退成功！");
							//当天考勤没数据，则显示签到按钮
							$('#signIn').hide();
							$('#signOut').hide();
						} else if (res == false) {
							layer.msg("签到10分钟才能签退哦！");
						} else {
							layer.msg("签退失败！");
						}
					},
					error: function() {
						alert("获取失败！！！");
					}
				})
			})
		</script>
	</body>
</html>
